﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using EyFramework.ORM;
using ShuJuGj.Entity;

namespace ShuJuGj.Core.Dao
{
    /// <summary>
    ///  SJGJ_SHUJUJI表的数据库操作
    /// </summary>
    public class SjgjShujujiDao : BaseDaoHis<SjgjShujuji>, ISjgjShujujiDao
    {
        public List<SjgjShujuji> GetListBy()
        {
            return Db.Queryable<SjgjShujuji>().Where(p=>p.FLAG=="Y").OrderBy(p => p.ORDERINDEX).ToList();
        }

        public bool delete()
        {
            return Db.Deleteable<SjgjShujuji>().In(new int[] { 1, 2 }).ExecuteCommand() >= 0;
        }

        public bool edit(string name, string zt, int num)
        {
            String sql = "update sjgj_shujuji set YWMC='" + name + "',FLAG='" + zt + "' where  ORDERINDEX=" + num + "";
            return Db.Updateable<SjgjJktjbgjl>(sql).ExecuteCommand() > 0;
        }

        /// <summary>
        /// 修改用户状态
        /// </summary>
        /// <param name="sjgjShujuji">改变的值</param>
        /// <returns></returns>
        public bool updateStates(SjgjShujuji sjgjShujuji)
        {
            return Db.Updateable(sjgjShujuji).UpdateColumns(it => new { it.FLAG }).ExecuteCommand() >= 0;
        }

        public List<SjgjShujuji> GetListByTaskType(string taskType)
        {
            return Db.Queryable<SjgjShujuji>().Where(p => p.TASK_TYPE == taskType).ToList();
        }
    }
}